<template>
	<view>

		<view class="mt70 pd">
			<view class="pr">
				<input type="text" value="" placeholder="搜索" class="kjjnmxeer" />
				<icon type="search" size="20" class="kkjdeeet" color="#999" />
			</view>
			<view class="row pt80 cen">
				<view class="jhhbsrrt fz28 z9 pr" :class="ikdx==idx?'act':''" v-for="(sd,idx) in jhhnsd" :key="idx" @tap="seertt(idx)">
					<view class="f_b pr">
						{{sd}}
						<text class="xiahuaxian"></text>
					</view>
				</view>
			</view>
			<view class="mt40" v-if="ikdx==0">
				<navigator :url="'MembersDetails?id='+sf.id+'&gid='+gid" class="row sderttr pt20 pm20" v-for="(sf,idx) in list">

					<view class="">
						<image :src="sf.avatar" class="yj useertty cz"></image>
					</view>
					<view class="cf fz32 pl20">
						{{sf.nickname}}
					</view>
				</navigator>
			</view>

			<view class="mt40 bgtmert" v-else>
				<uni-list>
					<!-- <uni-list-item title="A标签" :showArrow="false" rightText="6辆" @tap="hf('/pages/user/TransportManagement/LabelDetails')"></uni-list-item> 
					<uni-list-item title="B标签" :showArrow="false" rightText="6辆" @tap="hf('/pages/user/TransportManagement/LabelDetails')"></uni-list-item> -->
					<uni-list-item :showArrow="false" rightText="..空闲中" @tap="hf('/pages/user/TransportManagement/VehicleDetailsAdmin?carid='+idx)"  v-for="(sd,idx) in listcar" :key="idx">
						<view class="row sderttr  ">

							<view class="">
								<image :src="sd.image" class="yj useertty cz"></image>
							</view>
							<view class="cf fz32 pl20">
								{{sd.license}}
							</view>
						</view>
					</uni-list-item>
				</uni-list>
			</view>

		</view>

	</view>
</template>
<script>
	export default {
		data() {
			return {
				ikdx: 0,
				jhhnsd: [
					'群组成员',
					'群组车辆'
				],
				list:[],
				listcar:[],
				gid:''
			}
		},
		components: {

		},
		onLoad(e) {
			// this.member(8)
			// this.gid = 8
			console.log("得到上个页面的传参",e)
			this.member(e.id)
			this.gid = e.id
		},
		onShow(e) {
			// this.member(8)
			// this.gid = 8
			// this.member(e.gid)
			// this.gid = e.id
		},
		methods: {
			seertt(idx) {
				this.ikdx = idx
			},
			async member(id){
				let value=await this.get('/api/group/'+id)
				let values=await this.get('/api/group/'+id+'/cars')
				console.log("成员1",value)
				console.log("车辆",values)
				if(value.code==0){
					this.list=value.data.users
					this.listcar=values.data.cars
				}
			},
			async del(){
				var params=""
				var tuichu=await this.get("/api/group_user/"+this.gid+"/group",params,"DELETE")
				console.log("退出群组",tuichu)
				uni.navigateBack({
					delta:1
				})
			}
		},
		onNavigationBarButtonTap() {	
			var that=this
			if(this.ikdx==0){
				uni.showActionSheet({
					itemList:['退出群组'],
					itemColor:"#FC5A5A",
					success() {						
						uni.showModal({
							title: '',
							content: '您确定要退出本群组吗？',
							success(res) {
								if (res.confirm) {
									console.log('用户点击确定');
									that.del()
								} else if (res.cancel) {
									console.log('用户点击取消');
								}	
							}
						})
					}
				})
			} else if(this.ikdx==1){
				uni.showActionSheet({
					itemList:['新建标签','群信息','车辆体检','解散该群组'],
					success: (e) => {
						if(e.tapIndex==0){
							uni.navigateTo({
								url:'NewLabel?gid='+this.gid
							})
						} else if(e.tapIndex==1){
							uni.navigateTo({
								url:'GroupMembers?gid='+this.gid
							})
						}else if(e.tapIndex==2){
							uni.navigateTo({
								url:'VehicleCheckup?gid='+this.gid
							})
						}else if(e.tapIndex==3){
							
						}
					}
				})
			}
			
		},
		mounted() {

		},
	}
</script>
<style scoped>


</style>
